import 'package:common_utils/common_utils.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:taonile/config/config.dart';
import 'package:taonile/pages/splash_page.dart';
import 'package:taonile/provider/userinfo_provider.dart';
import 'package:taonile/routers/routers.dart';
import 'package:provider/provider.dart';
import 'package:taonile/utils/theme_color.dart';

class MyApplication extends StatelessWidget {
  const MyApplication({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    Routes.initRouter();
    LogUtil.init(tag: 'taoNiLe', isDebug: true, maxLen: 512);
    return ScreenUtilInit(
      designSize: const Size(750, 1500),
      minTextAdapt: true,
      splitScreenMode: true,
      builder: (context, child) {
        return ChangeNotifierProvider<UserInfoProvider>(
          create: (_) => UserInfoProvider(),
          child: MaterialApp(
            title: '淘你乐',
            onGenerateRoute: Routes.router.generator,
            theme: ThemeData(
              // primarySwatch: Colors.blue,
              primarySwatch: createMaterialColor(Config.colorMain),
              primaryColor: Config.colorMain,
              fontFamily: 'NotoSansSC-Medium',
              appBarTheme: AppBarTheme(
                  backgroundColor: Config.colorBg,
                  iconTheme: const IconThemeData(color: Config.colorText1),
                  titleTextStyle: TextStyle(fontSize: 34.sp, color: Config.colorText1),
                  elevation: 0.1),
            ),
            home: const SplashPage(),
            builder: EasyLoading.init(),
          ),
        );
      },
    );
  }
}
